import { interopDefault as _interopDefault, resolvePathSync as resolve } from 'mlly'

export const isPackageExists = (id: string): boolean => {
  try {
    return !!id.split('|').find((id) => !!resolve(id))
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
  } catch (e) {
    return false
  }
}

export const interopDefault = async <T>(module: Promise<any> | any): Promise<T> =>
  _interopDefault(await module)
